﻿    <script type="text/javascript">
        $(document).ready(function () {
            var p = new treepage();
            p.c = "Way.Bus.WMS.Controllers.WareHouseController";
            p.applyTo = "t1";
            p.onCommandClick = function (command, form, item) {
                if (command == "add" || command == "addroot") {
                    form.findbox("PARENTID").setdisabled(true);
                    var box = form.findbox("WHTYPE");
                    if (command == "addroot")
                        box.val(0);
                    if (command == "add") {
                        box.val(1);
                    }
                }
                if (command == "edit") {
                    if (item.ISREVIEWED == true || item.ISSUBMITED == true) {
                        form.setdisabled(true);
                    }
                    if (item.WHTYPE == 2) {
                        var box = form.findbox("STATUS");
                        box.disabled = false;
                        box.setdisabled(false);
                    }
                    else {
                        var box = form.findbox("STATUS");
                        box.setdisabled(true);
                        box.disabled = true;
                    }
                }
            }

            p.init();
        });

        function openWindow(data) {
            window.hostWMS = data.item.ID;
            $("#t2").dialog({
                title: "" + data.item.WAREHOUSENAME + "",
                width: 1200,
                height: 620,
                maximizable: false,
                cache: false,
                href: "Views/WMS/WareHouse/test.htm"
            });
        }
        function openAutoNext(data) {
            var id = webjs.newid();
            var str = '<div id="' + id + '">'
                    + '<table>'
                       + '<tr><td>行前缀</td><td><input class="easyui-validatebox" style="width:20px;" type="text" name="hqz" value="H"/></td><td>行开始</td><td><input class="easyui-numberspinner" style="width:50px;" min="1" type="text" name="hs" value="1"/></td><td>行结束</td><td><input class="easyui-numberspinner" style="width:50px;" min="1" type="text" name="he" value="10"/></td><td>行位数</td><td><input class="easyui-numberspinner" style="width:50px;" min="1" type="text" name="hws" value="3"/></td><td>仓库行设置</td></tr>'
                       + '<tr><td>列前缀</td><td><input class="easyui-validatebox" style="width:20px;" type="text" name="lqz" value="-L"/></td><td>列开始</td><td><input class="easyui-numberspinner" style="width:50px;" min="1" type="text" name="ls" value="1"/></td><td>列结束</td><td><input class="easyui-numberspinner" style="width:50px;" min="1" type="text" name="le" value="10"/></td><td>列位数</td><td><input class="easyui-numberspinner" style="width:50px;" min="1" type="text" name="lws" value="3"/></td><td>仓库列设置</td></tr>'
                       + '<tr><td>层前缀</td><td><input class="easyui-validatebox" style="width:20px;" type="text" name="cqz" value="-C"/></td><td>层数</td><td><input class="easyui-numberspinner" style="width:50px;" min="0" type="text" name="cs" value="3"/><td>货位层数</td></td></tr>'
                    + '</table>'
                    + '</div>';
            $(str).appendTo("body");
            $("#" + id + " .easyui-numberspinner").numberspinner();
            $("#" + id).dialog({
                title: "生成" + data.item.WAREHOUSENAME + "货位",
                width: 500,
                height: 200,
                maximizable: false,
                cache: false,
                buttons: [{
                    text: '生成',
                    handler: function () {
                        try {
                            var ddd = {};
                            $('#' + id + " input").each(function () {
                                if (this.name != "") {
                                    ddd[this.name] = this.value;
                                }
                            });
                            var e = data.sender.datasource.post("CreateLocator", "args=" + webjs.jsonval(ddd) + "&ActionItem=" + webjs.jsonval(data.item));
                            if (e && e.error) {
                                $.messager.alert('异常', e.errormsg, 'error');
                            }
                            else {
                                data.sender.datasource.p.tree.search(data);
                                $("#" + id).dialog('close');
                                $.messager.show({ title: '消息', msg: "生成" + data.item.WAREHOUSENAME + "货位完成。", showType: 'show' });
                            }
                        }
                        catch (e) {
                            $.messager.alert('异常', e, 'error');
                        }
                    }
                }],
                onClose: function () {
                    $("#" + id).remove();
                }
            });
        }
//        function openAutoNext(data) {
//            window.parID = data.item.ID;
//            window.whtype = data.item.WHTYPE;
//            $("#t3").dialog({
//                title: "生成" + data.item.WAREHOUSENAME + "下一级",
//                width: 300,
//                height: 400,
//                maximizable: false,
//                cache: false,
//                href: "Views/WMS/WareHouse/AutoNextWareHouse.htm"
//            });
//        }
        function SetPrintModel(data) {
            window.open("DesginManager/SetPrintModel.aspx?strController=" + data.sender.datasource.c, "_black", "width=300,height=200,left=200,top=200");
        }

      </script>
<div id="t1"></div>
<div id="t2"></div>
<div id="t3"></div>